import world.environment.pathfinder.*;
import world.environment.*;

public class MethodBehaviourEat extends world.possibilities.MethodBehaviour {
	
	
	public boolean init(Handler h) { return false; }
	
	public void act(Handler h) {
		
			AgentPassiveFood food;
			AgentActiveEvolved ag = (AgentActiveEvolved)h.getAgent();
			Handler h1,h2,h3,h4;

			if( (h1 = ag.getHandler("HandlerActionEat")) != null )
				if( ag.getWillStack.search(h) == -1 )
					if( h1.will() )
						if( (food = findFood()) != null ) {
							Map map = ag.getEnvironment().getMap();
							Pathfinder p = new Pathfinder(map);
							Stack intentions = p.findPath(map.getMapPoint(ag.position),map.getMapPoint(food.position));
							while( !intentions.empty() )
								ag.pushIntention( intentions.pop() );

	}
	
}